import request from '@/utils/request'

const startUrl = '/group'

/**
 * 创建团队
 */
export const createGroup = (userStore, description, address, expirationTime, neededNum, contactInfo, activityId, startTime, endTime) =>
    request.post(startUrl + '/create', {description, address, expirationTime, neededNum, contactInfo, activityId, startTime, endTime}, {
        headers: {
            'User-Token': userStore.$state.jwtEntity.jwt,
            'User-Secret-Key': userStore.$state.jwtEntity.signKeyStr
        }
    })

/**
 * 分页显示团队
 */
export const listPageGroup = (userStore,current, size, id, description, address, neededNum, groupStatus, contactInfo, alreadyNum, createId,activityId, startTime, endTime) =>
    request.post(startUrl + '/page', {current, size, id, description, address, neededNum, groupStatus, contactInfo, alreadyNum, createId,activityId, startTime, endTime}, {
        headers: {
            'User-Token': userStore.$state.jwtEntity.jwt,
            'User-Secret-Key': userStore.$state.jwtEntity.signKeyStr
        }
    })

/**
 * 分页显示团队,主页
 */
export const listPageGroupMain = (userStore,current, size, id, description, address, neededNum, groupStatus, contactInfo, alreadyNum, createId,activityId, startTime, endTime) =>
    request.post(startUrl + '/page/main', {current, size, id, description, address, neededNum, groupStatus, contactInfo, alreadyNum, createId,activityId, startTime, endTime}, {
        headers: {
            'User-Token': userStore.$state.jwtEntity.jwt,
            'User-Secret-Key': userStore.$state.jwtEntity.signKeyStr
        }
    })

/**
 * 加入团队
 */
export const joinGroupApi = (userStore, groupId) =>
    request.get(startUrl + '/join',{
        params: {
           'group_id': groupId
        },
        headers: {
            'User-Token': userStore.$state.jwtEntity.jwt,
            'User-Secret-Key': userStore.$state.jwtEntity.signKeyStr
        }
    })


/**
 * 所参加的团队
 */
export const listPageGroupSelf = (userStore, current, size, created, time) =>
    request.get(startUrl + '/page/self',{
        params: {
            'size': size,
            'current': current,
            'created': created,
            'time': time
        },
        headers: {
            'User-Token': userStore.$state.jwtEntity.jwt,
            'User-Secret-Key': userStore.$state.jwtEntity.signKeyStr
        }
    })


/**
 * 修改通知时间
 */

export const changeStartTimeNotice = (userStore, groupId, timeBeforehand) =>
    request.get(startUrl + '/start/change',{
        params: {
            'group_id': groupId,
            'time_beforehand': timeBeforehand,
        },
        headers: {
            'User-Token': userStore.$state.jwtEntity.jwt,
            'User-Secret-Key': userStore.$state.jwtEntity.signKeyStr
        }
    })

